package render

import (
	"fmt"

	// db "gsc-datasets/internal/db/dao"

	"github.com/go-chi/render"
)

func ErrInvalidRequest(friendlyMsg string) render.Renderer {
	return &AppBaseResponse{
		HTTPStatusCode: 400,
		StatusText:     "Invalid request.",
		ErrorText:      friendlyMsg,
	}
}

func ErrBadRequest(err error) render.Renderer {
	return &AppBaseResponse{
		Err:            err,
		HTTPStatusCode: 400,
		StatusText:     "Bad request.",
		ErrorText:      err.Error(),
	}
}

func ErrInvalidPath(err error) render.Renderer {
	return &AppBaseResponse{
		Err:            err,
		HTTPStatusCode: 400,
		StatusText:     "Invalid path.",
		ErrorText:      err.Error(),
	}
}

func ErrNotAuthorized(err error) render.Renderer {
	return &AppBaseResponse{
		Err:            err,
		HTTPStatusCode: 401,
		StatusText:     "Not Authorized.",
		ErrorText:      err.Error(),
	}
}

func ErrNotFoundRender(err error) render.Renderer {
	return &AppBaseResponse{
		Err:            err,
		HTTPStatusCode: 404,
		StatusText:     "Resource not found.",
		ErrorText:      err.Error(),
	}
}

func ErrUpstreamInvokeRender(err error) render.Renderer {
	return &AppBaseResponse{
		Err:            err,
		HTTPStatusCode: 500,
		StatusText:     "upstream invoke fail.",
		ErrorText:      err.Error(),
	}
}

func ErrDatabaseExec(err error, friendlyMsg string) render.Renderer {
	return &AppBaseResponse{
		Err:            err,
		HTTPStatusCode: 500,
		StatusText:     "执行数据库错误.",
		ErrorText:      friendlyMsg,
	}
}

func ErrCliRunRender(err error) render.Renderer {
	return &AppBaseResponse{
		Err:            err,
		HTTPStatusCode: 500,
		StatusText:     "客户端命令执行错误.",
		ErrorText:      err.Error(),
	}
}


func ErrRender(err error) render.Renderer {
	r := &AppBaseResponse{
		Err:            err,
		HTTPStatusCode: 500,
		StatusText:     "内部错误",
		ErrorText:      "内部错误",
	}
	fmt.Println("ErrRender=>", err)
	return r
}

// var ErrNotFound = &MockResponse{HTTPStatusCode: 404, StatusText: "Resource not found."}
